package com.ynunicom.midplatform.common.persistence.entity;

import com.ynunicom.midplatform.sys.user.SysUser;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.*;
import java.util.Date;

/**
 * 带 审计  实体基类
 *
 * @author duwei
 */
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
@Getter
@Setter
public abstract class AbstractAuditEntity extends AbstractIdEntity {

    @CreatedDate
    private Date createdTime;

    @LastModifiedDate
    private Date updatedTime;

    @CreatedBy
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn
    private SysUser createdBy;

    @LastModifiedBy
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn
    private SysUser updatedBy;
}
